﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HA.ModFlow.Domain.DomainLayer
{
    [Serializable]
    public class GeneralHead : MFPointSC, ICloneable
    {

        public GeneralHead(int i, int j, int k, int nrows, int ncolumns, int nlayers, int nPeriods)
            : base(i, j, k, nrows, ncolumns, nlayers, nPeriods)
        {



            this._conductance = new List<double>();


            this._head = new List<double>();

            for (int m = 0; m < nPeriods; m++)
            {

                this._conductance.Add(0);
                this._head.Add(0);

            }

        }

        public GeneralHead(int index, int nrows, int ncolumns, int nlayers, int nPeriods)
            : base(index, nrows, ncolumns, nlayers, nPeriods)
        {





            this._conductance = new List<double>();


            this._head = new List<double>();

            for (int m = 0; m < nPeriods; m++)
            {

                this._conductance.Add(0);
                this._head.Add(0);

            }


        }





        List<double> _conductance;

        public List<double> Conductance
        {
            get { return _conductance; }

        }


        public double FirstConductance
        {

            get
            {

                return this._conductance[0];


            }

            set
            {
                this._conductance[0] = value;
            }

        }




        List<double> _head;

        public List<double> Head
        {
            get { return _head; }

        }

        public double FirstHead
        {


            get
            {

                return this._head[0];


            }

            set
            {
                this._head[0] = value;
            }

        }



        public object Clone()
        {

            GeneralHead river = (GeneralHead)this.MemberwiseClone();


            river._conductance = new List<double>();

            river._head = new List<double>();




            river.Conductance.AddRange(this.Conductance);

            river.Head.AddRange(this.Head);

            return river;


        }





        public override void OnResetSperiods(int nPeriods)
        {
            base.OnResetSperiods(nPeriods);

            if (this.NPeriods == nPeriods)
            {
                return;

            }

            if (this.NPeriods < nPeriods)
            {
                int nSub = nPeriods - this.NPeriods;

                for (int i = 0; i < nSub; i++)
                {
                    this.Head.Add(this.Head[0]);
                    this.Conductance.Add(this.Conductance[0]);
                }
            }

            else
            {
                int nSub = this.NPeriods - nPeriods;
                this.Head.RemoveRange(nPeriods, nSub);
                this.Conductance.RemoveRange(nPeriods, nSub);
            }
            this.NPeriods = nPeriods;
        }

    }
}
